import react from '@vitejs/plugin-react'
import { loadEnv } from 'vite'

export default ({
  mode
}) => {
  const { VITE_FLOWABLE_URL } = loadEnv(mode, process.cwd())

  return {
    base: './',
    plugins: [react()],
    server: {
      open: true,
      proxy: {
        '/flowable-ui/': {
          target: VITE_FLOWABLE_URL,
          rewrite: (path) => path.replace(/^\/flowable-ui/, '')
        }
      }
    }
  }
}
